package model

import (
	"smart-health-platforms/config"
	"time"
)

type BargainWater struct {
	Id                uint32    `gorm:"column:id;type:int UNSIGNED;primaryKey;not null;" json:"id"`
	UserId            int32     `gorm:"column:user_id;type:int;default:NULL;" json:"user_id"`
	BargainActivityId int32     `gorm:"column:bargain_activity_id;type:int;default:NULL;" json:"bargain_activity_id"`
	BargainPrice      float64   `gorm:"column:bargain_price;type:decimal(10, 2);default:NULL;" json:"bargain_price"`
	OrderSn           string    `gorm:"column:order_sn;type:varchar(255);default:NULL;" json:"order_sn"`
	CreatedAt         time.Time `gorm:"column:created_at;type:datetime(3);default:CURRENT_TIMESTAMP(3);" json:"created_at"`
}

func (b *BargainWater) TableName() string {
	return "bargain_water"
}
func (b *BargainWater) AddBargainWater() error {
	return config.DB.Create(&b).Error
}
func (b *BargainWater) UpdateBargainWater() error {
	return config.DB.Model(&b).Updates(&b).Error
}
func (b *BargainWater) DeletedBargainWater() error {
	return config.DB.Model(&b).Delete(&b).Error
}
